<!--
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author FIRE
-->
<template>
  <div style="background: #fff; height: 100%; padding: 20px">
    <div style="display: flex">
      <!-- 基本信息 -->
      <div style="border: #eee 1px solid; padding: 10px; margin-right: 10px">
        <div style="display: flex; margin-bottom: 10px; padding-left: 30px">
          <div style="width: 300px">
            <div style="color: #aaa">项目编号</div>
            <div style="font-size: 18px">{{ record.projectno }}</div>
          </div>
          <div>
            <div style="color: #aaa">项目名称</div>
            <div style="font-size: 18px">{{ record.projectname }}</div>
          </div>
        </div>
        <BasicForm @register="registerForm">
          <template #plane>
            <!-- 只能显示一个字符串 -->
            <!-- {{ record.actualduration || '-' }} {{ '/'  }} {{ record.pmZone.plannedduration || '-' }} -->
            <a-input v-model:value="plane" disabled />
          </template>
          <template #sgjd="{ record: childRecord }">
            <div>
              <a-steps :current="current">
                <a-step v-for="(item, key) in statusMap" :key="key">
                  <template #title>
                    <!-- <div :style="{color:current + 1 > key?'green':''}"> -->
                    <div style="font-weight: bold">
                      {{
                        key == 1
                          ? '施工准备'
                          : key == 2
                          ? '施工中'
                          : key == 3
                          ? '完工待验'
                          : key == 4
                          ? '验收完成'
                          : ''
                      }}</div
                    >
                    <!-- </div> -->
                  </template>
                  <template #description>
                    <div
                      v-if="item.length <= 4"
                      style="position: relative; left: -35px; margin-top: 10px; padding-right: 5px"
                    >
                      <div v-for="item2 in item" :key="item2.code">
                        <!-- <Icon v-if="item2.status === '1'" icon="ant-design:check-outlined" />
                        <Icon v-else icon="ant-design:close-outlined" /> {{ item2.name }} -->

                        <div v-if="item2.status == '1'" style="color: green">
                          <Icon icon="ant-design:check-outlined" /> {{ item2.name }}
                        </div>
                        <div v-else style="color: #aaa">
                          <Icon icon="ant-design:close-outlined" /> {{ item2.name }}
                        </div>
                      </div>
                    </div>
                    <div
                      v-else
                      style="position: relative; left: -35px; margin-top: 10px; padding-right: 5px"
                    >
                      <a-row>
                        <template v-for="(item2, index) in item" :key="item2.code">
                          <a-col :span="index % 2 != 0 ? 14 : 10">
                            <div v-if="item2.status == '1'" style="color: green">
                              <Icon icon="ant-design:check-outlined" /> {{ item2.name }}
                            </div>
                            <div v-else style="color: #aaa">
                              <Icon icon="ant-design:close-outlined" /> {{ item2.name }}
                            </div>
                          </a-col>
                        </template>
                      </a-row>
                    </div>
                  </template>
                </a-step>

                <!-- <a-step>
                  <template #title>施工准备</template>
                  <template #description>
                    <div style="font-size: 12px;position:relative;left: -35px;margin-top: 10px;">
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 风险评估
                      </div>
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 技术文件审批
                      </div>
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 合同签订
                      </div>
                    </div>
  
                  </template>
                </a-step>
                <a-step title="施工中">
                  <template #description>
                    <div style="display: flex;font-size: 12px;position:relative;left: -35px;margin-top: 10px;">
                      <div style="margin-right: 20px;">
                        <div>
                          <Icon icon="ant-design:check-circle-outlined" /> 进场通知
                        </div>
                        <div>
                          <Icon icon="ant-design:check-circle-outlined" /> 中间验收
                        </div>
                        <div>
                          <Icon icon="ant-design:check-circle-outlined" /> 接水作业
                        </div>
                        <div>
                          <Icon icon="ant-design:check-circle-outlined" /> 撤场通知
                        </div>
                      </div>
                      <div>
                        <div>
                          <Icon icon="ant-design:check-circle-outlined" /> 进场确认
                        </div>
                        <div>
                          <Icon icon="ant-design:check-circle-outlined" /> 试压冲洗
                        </div>
                        <div>
                          <Icon icon="ant-design:check-circle-outlined" /> 申请挂表
                        </div>
                        <div>
                          <Icon icon="ant-design:check-circle-outlined" /> 撤场确认
                        </div>
                      </div>
                    </div>
  
                  </template>
                </a-step>
                <a-step title="完工待验">
                  <template #description>
                    <div style="display: flex;font-size: 12px;position:relative;left: -35px;margin-top: 10px;">
                      <div style="margin-right: 20px;">
                        <div>
                          <Icon icon="ant-design:close-outlined" /> 水表验收
                        </div>
                        <div>
                          <Icon icon="ant-design:close-outlined" /> 预验收
                        </div>
                        <div>
                          <Icon icon="ant-design:close-outlined" /> 核对材料
                        </div>
                        <div>
                          <Icon icon="ant-design:close-outlined" /> 验收通过
                        </div>
                      </div>
                      <div >
                        <div>
                          <Icon icon="ant-design:close-outlined" /> 通水推送报装
                        </div>
                        <div>
                          <Icon icon="ant-design:close-outlined" /> 水质检测
                        </div>
                        <div>
                          <Icon icon="ant-design:close-outlined" /> 验收推送
                        </div>
                      </div>
                    </div>
                  </template>
                </a-step>
                <a-step title="验收完成">
                  <template #description>
                    <div  style="font-size: 12px;position:relative;left: -35px;margin-top: 10px;">
                      <div>
                        <Icon icon="ant-design:close-outlined" /> 发起结算
                      </div>
                      <div>
                        <Icon icon="ant-design:close-outlined" /> 结算完成
                      </div>
                    </div>
                  </template>
                </a-step> -->
                <a-step title="项目结束"> </a-step>
              </a-steps>
            </div>
          </template>
        </BasicForm>
        <div v-if="hasPermission(['info:mount:view'])">
          <BasicForm @register="registerFormMount"></BasicForm>
        </div>
      </div>
      <!-- 打卡 -->
      <div style="border: #eee 1px solid; padding: 10px">
        <div style="margin-bottom: 10px">
          <span style="display: inline-block; width: 5px; height: 12px; background: #aaa"></span>
          <span style="font-size: 18px"> 打卡记录</span>
        </div>
        <div :style="{ width: '350px', border: '1px solid #d9d9d9', borderRadius: '4px' }">
          <a-calendar
            v-model:value="dateValue"
            :fullscreen="false"
            @panelChange="onPanelChange"
            valueFormat="YYYY-MM-DD"
          >
            <template #dateCellRender="{ current }">
              <div
                style="
                  width: 100%;
                  height: 100%;
                  display: flex;
                  justify-content: center;
                  align-items: center;
                  font-size: 10px;
                  color: green;
                "
              >
                {{ getListData(current) }}
              </div>
            </template>
          </a-calendar>
        </div>
        <div
          @click="buka"
          style="border: 1px solid #d9d9d9; text-align: center; padding: 20px"
          v-auth="'btn:proj:buka'"
          >补卡</div
        >

        <div style="margin: 20px 0"> 进场日期：{{ record.pmStatus?.enDate }} </div>
        <div> 撤场日期：{{ record.pmStatus?.exDate }} </div>
      </div>
    </div>

    <div style="border: #eee 1px solid; padding: 10px; margin-top: 10px">
      <BasicForm @register="registerForm2">
        <template #sgjd="{ record: childRecord }">
          <div>
            <a-steps :current="current">
              <a-step v-for="(item, key) in statusMap" :key="key">
                <template #title>
                  <!-- <div :style="{color:current + 1 > key?'green':''}"> -->
                  <div style="font-weight: bold">
                    {{
                      key == 1
                        ? '施工准备'
                        : key == 2
                        ? '施工中'
                        : key == 3
                        ? '完工待验'
                        : key == 4
                        ? '验收完成'
                        : ''
                    }}</div
                  >
                  <!-- </div> -->
                </template>
                <template #description>
                  <div
                    v-if="item.length <= 4"
                    style="position: relative; left: -35px; margin-top: 10px; padding-right: 5px"
                  >
                    <div v-for="item2 in item" :key="item2.code">
                      <!-- <Icon v-if="item2.status === '1'" icon="ant-design:check-outlined" />
                      <Icon v-else icon="ant-design:close-outlined" /> {{ item2.name }} -->

                      <div v-if="item2.status == '1'" style="color: green">
                        <Icon icon="ant-design:check-outlined" /> {{ item2.name }}
                      </div>
                      <div v-else style="color: #aaa">
                        <Icon icon="ant-design:close-outlined" /> {{ item2.name }}
                      </div>
                    </div>
                  </div>
                  <div
                    v-else
                    style="position: relative; left: -35px; margin-top: 10px; padding-right: 5px"
                  >
                    <a-row>
                      <template v-for="(item2, index) in item" :key="item2.code">
                        <a-col :span="index % 2 != 0 ? 14 : 10">
                          <div v-if="item2.status == '1'" style="color: green">
                            <Icon icon="ant-design:check-outlined" /> {{ item2.name }}
                          </div>
                          <div v-else style="color: #aaa">
                            <Icon icon="ant-design:close-outlined" /> {{ item2.name }}
                          </div>
                        </a-col>
                      </template>
                    </a-row>
                  </div>
                </template>
              </a-step>

              <!-- <a-step>
                <template #title>施工准备</template>
                <template #description>
                  <div style="font-size: 12px;position:relative;left: -35px;margin-top: 10px;">
                    <div>
                      <Icon icon="ant-design:check-circle-outlined" /> 风险评估
                    </div>
                    <div>
                      <Icon icon="ant-design:check-circle-outlined" /> 技术文件审批
                    </div>
                    <div>
                      <Icon icon="ant-design:check-circle-outlined" /> 合同签订
                    </div>
                  </div>

                </template>
              </a-step>
              <a-step title="施工中">
                <template #description>
                  <div style="display: flex;font-size: 12px;position:relative;left: -35px;margin-top: 10px;">
                    <div style="margin-right: 20px;">
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 进场通知
                      </div>
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 中间验收
                      </div>
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 接水作业
                      </div>
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 撤场通知
                      </div>
                    </div>
                    <div>
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 进场确认
                      </div>
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 试压冲洗
                      </div>
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 申请挂表
                      </div>
                      <div>
                        <Icon icon="ant-design:check-circle-outlined" /> 撤场确认
                      </div>
                    </div>
                  </div>

                </template>
              </a-step>
              <a-step title="完工待验">
                <template #description>
                  <div style="display: flex;font-size: 12px;position:relative;left: -35px;margin-top: 10px;">
                    <div style="margin-right: 20px;">
                      <div>
                        <Icon icon="ant-design:close-outlined" /> 水表验收
                      </div>
                      <div>
                        <Icon icon="ant-design:close-outlined" /> 预验收
                      </div>
                      <div>
                        <Icon icon="ant-design:close-outlined" /> 核对材料
                      </div>
                      <div>
                        <Icon icon="ant-design:close-outlined" /> 验收通过
                      </div>
                    </div>
                    <div >
                      <div>
                        <Icon icon="ant-design:close-outlined" /> 通水推送报装
                      </div>
                      <div>
                        <Icon icon="ant-design:close-outlined" /> 水质检测
                      </div>
                      <div>
                        <Icon icon="ant-design:close-outlined" /> 验收推送
                      </div>
                    </div>
                  </div>
                </template>
              </a-step>
              <a-step title="验收完成">
                <template #description>
                  <div  style="font-size: 12px;position:relative;left: -35px;margin-top: 10px;">
                    <div>
                      <Icon icon="ant-design:close-outlined" /> 发起结算
                    </div>
                    <div>
                      <Icon icon="ant-design:close-outlined" /> 结算完成
                    </div>
                  </div>
                </template>
              </a-step> -->
              <a-step title="项目结束"> </a-step>
            </a-steps>
          </div>
        </template>
      </BasicForm>

      <div style="padding: 10px">
        <div style="background-color: #eee; text-align: center; display: flex; padding: 30px 10px">
          <div style="flex: 1">
            <div
              ><span style="font-size: 20px">
                {{ record.pmStatus ? record.pmStatus.xjTimes : 0 }}</span
              >次</div
            >
            <div>巡检次数</div>
          </div>
          <div style="flex: 1">
            <div
              ><span style="font-size: 20px">
                {{ record.pmStatus ? record.pmStatus.chgTimes : 0 }}</span
              >次</div
            >
            <div>设计变更</div>
          </div>
          <div style="flex: 1">
            <div
              ><span style="font-size: 20px">
                {{ record.pmStatus ? record.pmStatus.signTimes : 0 }}</span
              >次</div
            >
            <div>签证次数</div>
          </div>
          <div style="flex: 1">
            <div
              ><span style="font-size: 20px">
                {{ record.pmStatus ? record.pmStatus.waterjobTimes : 0 }}</span
              >次</div
            >
            <div>接水次数</div>
          </div>
          <div style="flex: 1">
            <div
              ><span style="font-size: 20px">
                {{ record.pmStatus ? record.pmStatus.feiguanTimes : 0 }}</span
              >次</div
            >
            <div>废管次数</div>
          </div>
          <div style="flex: 1">
            <div
              ><span style="font-size: 20px">
                {{ record.pmStatus ? record.pmStatus.fendanTimes : 0 }}</span
              >次</div
            >
            <div>分单次数</div>
          </div>
        </div>
      </div>

      <!-- justify-content: space-between; -->
      <div style="display: flex; flex-wrap: wrap; padding: 10px">
        <a-button @click="xmwj" v-auth="'btn:proj:file'" class="mr-5 mb-5">
          {{ t('项目文件') }}
        </a-button>
        <a-button @click="xmzb" v-auth="'btn:zhuobao'" class="mr-5 mb-5">
          {{ t('项目周报') }}
        </a-button>
        <a-button @click="handleBzfj" v-auth="'btn:proj:bz:file'" class="mr-5 mb-5">
          {{ t('报装附件') }}
        </a-button>

        <a-button @click="handleBzLog" v-auth="'btn:proj:bz:log'" class="mr-5 mb-5">
          {{ t('报装日志') }}
        </a-button>

        <a-button @click="handleGCLog" v-auth="'btn:proj:log'" class="mr-5 mb-5">
          {{ t('工程日志') }}
        </a-button>

        <Dropdown placement="top" :trigger="['click']" @click="handleSetProject">
          <a-button @click.prevent v-auth="'btn:proj:material:info'" class="mr-5 mb-5">
            {{ t('材料信息') }}
          </a-button>
          <template #overlay>
            <Menu>
              <MenuItem @click="handleClqd" v-if="hasPermission(['btn:proj:material:infoclqd'])">
                <span>材料清单</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleClsh" v-if="hasPermission(['btn:proj:material:infoclsh'])">
                <span>材料收货</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleClcj" v-if="hasPermission(['btn:proj:material:infoclcj'])">
                <span>材料抽检</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleClqg" v-if="hasPermission(['btn:proj:material:infoclqg'])">
                <span>材料请购</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleClkl" v-if="hasPermission(['btn:proj:material:infocllk'])">
                <span>材料库领</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleShxq" v-if="hasPermission(['btn:proj:material:infoshxq'])">
                <span>送货需求</span>
              </MenuItem>
              <!-- <MenuDivider /> -->
            </Menu>
          </template>
        </Dropdown>
        <a-button @click="handleSbqd" v-auth="'btn:proj:water:list'" class="mr-5 mb-5">
          {{ t('水表清单') }}
        </a-button>

        <a-button @click="handleXmht" v-auth="'btn:proj:hetong:manage'" class="mr-5 mb-5">
          {{ t('合同管理') }}
        </a-button>

        <!-- <Dropdown placement="bottom" :trigger="['click']">
          <a-button @click.prevent v-auth="'proj:info:pmProjectinformation:edit'">
            {{ t('安全文件') }}
          </a-button>
          <template #overlay>
            <Menu>
              <MenuItem>
              <span>123456</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem>
              <span>66666</span>
              </MenuItem>
            </Menu>
          </template>
        </Dropdown> -->
        <Dropdown placement="top" :trigger="['click']" @click="handleSetProject">
          <a-button @click.prevent v-auth="'btn:proj:process:ctrl'" class="mr-5 mb-5">
            {{ t('过程控制') }}
          </a-button>
          <template #overlay>
            <Menu>
              <MenuItem @click="handleXjList" v-if="hasPermission(['btn:proj:process:ctrlxj'])">
                <span>巡检</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleSycxList" v-if="hasPermission(['btn:proj:process:ctrlsycx'])">
                <span>试压冲洗</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleYqhmList" v-if="hasPermission(['btn:proj:process:ctrlyqhm'])">
                <span>延期豁免</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleJszyList" v-if="hasPermission(['btn:proj:process:ctrljszy'])">
                <span>接水作业</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleSzjcList" v-if="hasPermission(['btn:proj:process:ctrlszjc'])">
                <span>水质检测</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem
                @click="handleTstsbzList"
                v-if="hasPermission(['btn:proj:process:ctrltstsbz'])"
              >
                <span>通水推送报装</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleCdList" v-if="hasPermission(['btn:proj:process:ctrlcd'])">
                <span>裁断</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleFdList" v-if="hasPermission(['btn:proj:process:ctrlfd'])">
                <span>分单</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleGbList" v-if="hasPermission(['btn:proj:process:ctrlgb'])">
                <span>挂表</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleCcList" v-if="hasPermission(['btn:proj:process:ctrlcc'])">
                <span>撤场</span>
              </MenuItem>
              <MenuDivider />
              <MenuItem @click="handleGdfcList" v-if="hasPermission(['btn:proj:process:ctrlgdfc'])">
                <span>管道废除</span>
              </MenuItem>
            </Menu>
          </template>
        </Dropdown>
      </div>
    </div>
    <!-- 项目文件 -->
    <BasicDrawer v-bind="$attrs" :showFooter="false" @register="registerDrawer" width="70%">
      <template #title>
        <Icon :icon="getTitle.icon" class="pr-1 m-1" />
        <span> 项目文件 ({{ record.projectname }}-{{ record.projectno }}) </span>
      </template>
      <xmwjindex v-if="record.projectno" :projectno="record.projectno"></xmwjindex>
    </BasicDrawer>
    <!-- 项目周报 -->
    <BasicDrawer v-bind="$attrs" :showFooter="false" @register="registerDrawexmzb" width="70%">
      <template #title>
        <Icon :icon="getTitle.icon" class="pr-1 m-1" />
        <span> 项目周报 ({{ record.projectname }}-{{ record.projectno }}) </span>
      </template>
      <xmzbindex v-if="record.projectno" :projectno="record.projectno"></xmzbindex>
    </BasicDrawer>

    <!-- 报装附件列表 -->
    <BasicDrawer
      v-bind="$attrs"
      :showFooter="true"
      :showOkBtn="false"
      @register="registerAttachmentDrawer"
      width="80%"
    >
      <template #title>
        <Icon :icon="getTitle.icon" class="pr-1 m-1" />
        <span> 报装附件 ({{ record.projectname }}-{{ record.projectno }}) </span>
      </template>
      <AttachmentList :projectno="record.projectno" />
    </BasicDrawer>
    <!-- 报装日志列表 -->
    <BasicDrawer
      v-bind="$attrs"
      :showFooter="true"
      :showOkBtn="false"
      @register="registerBzLogDrawer"
      width="80%"
    >
      <template #title>
        <Icon :icon="getTitle.icon" class="pr-1 m-1" />
        <span> 报装日志 ({{ record.projectname }}-{{ record.projectno }}) </span>
      </template>
      <BzLogList :projectno="record.projectno" />
    </BasicDrawer>

    <!-- 工程日志列表 -->
    <BasicDrawer
      v-bind="$attrs"
      title="工程日志"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerGcLogDrawer"
      width="80%"
    >
      <GcLogList :projectno="record.projectno" />
    </BasicDrawer>

    <!-- 项目合同列表 -->
    <BasicDrawer
      v-bind="$attrs"
      title="工程项目合同"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerXmhtDrawer"
      width="80%"
    >
      <XmhtList :projectno="record.projectno" />
    </BasicDrawer>

    <!-- 水表清单列表 -->
    <BasicDrawer
      v-bind="$attrs"
      title="水表清单"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerSbqdDrawer"
      width="80%"
    >
      <template #title>
        <Icon :icon="getTitle.icon" class="pr-1 m-1" />
        <span> 水表清单 ({{ record.projectname }}-{{ record.projectno }}) </span>
      </template>
      <SbqdList :projectno="record.projectno" />
    </BasicDrawer>

    <!-- 材料 -->
    <BasicDrawer
      v-bind="$attrs"
      title="材料清单"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerClqdDrawer"
      width="80%"
    >
      <ClqdList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="材料收货"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerClshDrawer"
      width="80%"
    >
      <ClshList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="材料抽检"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerClcjDrawer"
      width="80%"
    >
      <ClcjList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="材料请购"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerClqgDrawer"
      width="80%"
    >
      <ClqgList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="材料库领"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerClklDrawer"
      width="80%"
    >
      <ClklList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="送货需求"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerShxqDrawer"
      width="80%"
    >
      <ShxqList :projectno="record.projectno" />
    </BasicDrawer>

    <!-- 过程控制 -->
    <BasicDrawer
      v-bind="$attrs"
      title="巡检"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerXjDrawer"
      width="80%"
    >
      <XjList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="试压冲洗"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerSycxDrawer"
      width="80%"
    >
      <SycxList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="延期豁免"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerYqhmDrawer"
      width="80%"
    >
      <YqhmList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="接水作业"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerJszyDrawer"
      width="80%"
    >
      <JszyList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="水质检测"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerSzjcDrawer"
      width="80%"
    >
      <SzjcList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="通水推送报装"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerTstsbzDrawer"
      width="80%"
    >
      <TstsbzList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="裁断"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerCdDrawer"
      width="80%"
    >
      <CdList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="分单"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerFdDrawer"
      width="80%"
    >
      <FdList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="挂表"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerGbDrawer"
      width="80%"
    >
      <GbList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="撤场"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerCcDrawer"
      width="80%"
    >
      <CcList :projectno="record.projectno" />
    </BasicDrawer>
    <BasicDrawer
      v-bind="$attrs"
      title="管道废除"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerGdfcDrawer"
      width="80%"
    >
      <GdfcList :projectno="record.projectno" />
    </BasicDrawer>
  </div>
</template>
<script lang="ts">
  export default defineComponent({
    name: 'ViewsProjInfoPmProjectinformationDetailsForm',
    components: { Menu, Dropdown, MenuItem: Menu.Item, MenuDivider: Menu.Divider },
  });
</script>
<script lang="ts" setup>
  import { defineComponent, ref, computed, onMounted, watch, onUnmounted } from 'vue';
  import { Dayjs } from 'dayjs';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { router } from '/@/router';
  import { Icon } from '/@/components/Icon';
  import { BasicForm, FormSchema, useForm } from '/@/components/Form';
  import { BasicDrawer, useDrawer } from '/@/components/Drawer';
  import {
    PmProjectinformation,
    pmProjectinformationSave,
    pmProjectinformationForm,
  } from '/@/api/proj/info/pmProjectinformation';
  import { formSet } from '/@/api/test/testData';
  import { formSchemas } from '/@/utils/custom';
  import { Menu, Dropdown } from 'ant-design-vue';
  import { pmJournalSave, pmJournalListCardData } from '/@/api/proj/journal/pmJournal';
  import { useUserStore } from '/@/store/modules/user';
  import { switchProject } from '/@/api/zfgsCommon/zfgsCommon';
  import xmwjindex from '/@/views/proj/safe/pmRiskassessment/index.vue';
  import xmzbindex from '/@/views/proj/weekly/pmWeekly/list.vue';

  import AttachmentList from '../../attachment/pmAttachment/list.vue';
  import BzLogList from './bzLog.vue';

  import GcLogList from '/@/views/proj/log/pmPjournal/list.vue';
  import XmhtList from '/@/views/proj/contract/pmContract2/list.vue';

  import SbqdList from '/@/views/material/nature/pmProjectNature/list.vue';

  // 材料
  import ClqdList from '/@/views/material/bom/pmMaterial/list.vue';
  import ClshList from '/@/views/material/receive/pmMaterialneedArr/list.vue';
  import ClcjList from '/@/views/material/check/pmMaterialcheck/list.vue';
  import ClqgList from '/@/views/material/pu/pmPuAppvouch/list.vue';
  import ClklList from '/@/views/material/app/pmMaterialAppVouch/list.vue';
  import ShxqList from '/@/views/material/arrival/pmPuArrivalvouch/list.vue';

  // 过程控制
  import XjList from '/@/views/proj/xj/pmInspection/list.vue';
  import SycxList from '/@/views/process/pressure/pmPressuretest/list.vue';
  import YqhmList from '/@/views/process/delay/pmDelay/list.vue';
  import JszyList from '/@/views/process/job/pmConnectwaterjob/list.vue';
  import SzjcList from '/@/views/process/analysis/pmWateranalysis/list.vue';
  import TstsbzList from '/@/views/process/water/pmWater/list.vue';
  import CdList from '/@/views/process/cut/pmProjectadjudicationcut/list.vue';
  import FdList from '/@/views/process/fd/pmProjectSegmentation/list.vue';
  import GbList from '/@/views/process/meter/pmWatermeter/list.vue';
  import CcList from '/@/views/proj/enex/withdrawal/list.vue';
  import GdfcList from '/@/views/process/pipe/pmWastepipeData/list.vue';

  import { usePermission } from '/@/hooks/web/usePermission';
  const { hasPermission } = usePermission();
  const userStore = useUserStore();

  import { useLoading } from '/@/components/Loading';
  import { handleExport } from '/@/utils/export';
  const [openFullLoading, closeFullLoading] = useLoading({
    tip: '加载中...',
  });
  const emit = defineEmits(['success', 'register']);

  const { t } = useI18n('proj.info.pmProjectinformation');
  const { showMessage } = useMessage();
  const record = ref<PmProjectinformation>({ pmStatus: {} } as PmProjectinformation);

  // 拼装 record.plane 字段 值为{{ record.actualduration || '-' }} {{ '/'  }} {{ record.pmZone.plannedduration || '-' }}
  const plane = computed(() => {
    return `${record.value?.actualduration || '-'} / ${
      record.value?.pmZone.plannedduration || '-'
    }`;
  });

  const getTitle = computed(() => ({
    icon: router.currentRoute.value.meta.icon || 'ant-design:book-outlined',
    value: t('项目基本信息'),
  }));
  let statusMap = ref<any>({});
  let current = ref<any>(2);

  let dateValue = ref('');

  async function onPanelChange(value, mode) {
    console.log(value, mode, '1111');
    dateValue.value = value;
    dkjl();
  }

  let date = ref<any>([]);
  const getListData = (value: Dayjs) => {
    let str = '';
    date.value.forEach((item) => {
      var myDate = new Date(item.ddate);
      if (
        // item.iyear == value.year() &&
        // item.imonth == value.month() + 1 &&
        // item.iday == value.date()
        myDate.getFullYear() == value.year() &&
        myDate.getMonth() == value.month() &&
        myDate.getDate() == value.date()
      ) {
        // str = '已打卡';
        str = '✓';
      }
    });

    return str;
  };

  // const inputFormSchemas: FormSchema[] = [
  //   {
  //     label: t('申请主体'),
  //     field: 'applybodyname',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('联系人'),
  //     field: 'contacts',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('联系电话'),
  //     field: 'mobile',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('工程类型'),
  //     field: 'firstbusinessname',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('安装地址'),
  //     field: 'projectaddress',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('接件时间'),
  //     field: 'projectno',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('设计人员'),
  //     field: 'projectno',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('预算人员'),
  //     field: 'projectno',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('承包商'),
  //     field: 'pmZone.pmContractor.name',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('施工人员'),
  //     field: 'projectno',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('施工人员电话'),
  //     field: 'projectno',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('项目负责人'),
  //     field: 'pmZone.leaderUser.userName',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('技术负责人'),
  //     field: 'pmZone.techUser.userName',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('安全负责人'),
  //     field: 'pmZone.securityUser.userName',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('材料负责人'),
  //     field: 'pmZone.materialUser.userName',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('资料负责人'),
  //     field: 'pmZone.dataUser.userName',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('监理'),
  //     field: 'pmZone.pmSupervision.name',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('工期'),
  //     field: 'trueprojecttermlimit',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('项目特征'),
  //     field: 'projecttype',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },
  //   {
  //     label: t('任务分配备注'),
  //     field: 'remarks',
  //     component: 'Input',
  //     dynamicDisabled: true,
  //   },

  //   {
  //     label: t('施工进度'),
  //     field: 'sgjd',
  //     component: 'Input',
  //     slot: 'sgjd',
  //     colProps: { lg: 24, md: 24 },
  //   },

  // ];
  let inputFormSchemas: FormSchema[] = [];

  const [registerAttachmentDrawer, { openDrawer: openAttachmentDrawer }] = useDrawer();
  const [registerBzLogDrawer, { openDrawer: openBzLogDrawer }] = useDrawer();
  const [registerGcLogDrawer, { openDrawer: openGcLogDrawer }] = useDrawer();
  const [registerXmhtDrawer, { openDrawer: openXmhtDrawer }] = useDrawer();
  const [registerSbqdDrawer, { openDrawer: openSbqdDrawer }] = useDrawer();

  // 材料
  const [registerClqdDrawer, { openDrawer: openClqdDrawer }] = useDrawer();
  const [registerClshDrawer, { openDrawer: openClshDrawer }] = useDrawer();
  const [registerClcjDrawer, { openDrawer: openClcjDrawer }] = useDrawer();
  const [registerClqgDrawer, { openDrawer: openClqgDrawer }] = useDrawer();
  const [registerClklDrawer, { openDrawer: openClklDrawer }] = useDrawer();
  const [registerShxqDrawer, { openDrawer: openShxqDrawer }] = useDrawer();
  // 过程控制
  const [registerXjDrawer, { openDrawer: openXjListDrawer }] = useDrawer();
  const [registerSycxDrawer, { openDrawer: openSycxListDrawer }] = useDrawer();
  const [registerYqhmDrawer, { openDrawer: openYqhmListDrawer }] = useDrawer();
  const [registerJszyDrawer, { openDrawer: openJszyListDrawer }] = useDrawer();
  const [registerSzjcDrawer, { openDrawer: openSzjcListDrawer }] = useDrawer();
  const [registerTstsbzDrawer, { openDrawer: openTstsbzListDrawer }] = useDrawer();
  const [registerCdDrawer, { openDrawer: openCdListDrawer }] = useDrawer();
  const [registerFdDrawer, { openDrawer: openFdListDrawer }] = useDrawer();
  const [registerGbDrawer, { openDrawer: openGbListDrawer }] = useDrawer();
  const [registerCcDrawer, { openDrawer: openCcListDrawer }] = useDrawer();
  const [registerGdfcDrawer, { openDrawer: openGdfcListDrawer }] = useDrawer();

  const [registerDrawer, { openDrawer, closeDrawer }] = useDrawer();
  const [registerDrawexmzb, { openDrawer: openDrawerxmzb, closeDrawer: closeDrawerxmzb }] =
    useDrawer();

  const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm();
  const [registerForm2, { resetFields: resetFields2 }] = useForm({
    labelWidth: 120,
    schemas: [
      {
        label: t('施工进度'),
        field: 'sgjd',
        component: 'Input',
        componentProps: {
          maxlength: 100,
        },
        slot: 'sgjd',
      },
    ],
    baseColProps: { lg: 24, md: 24 },
  });

  const [
    registerFormMount,
    { resetFields: resetFieldsMount, setFieldsValue: setFieldsValueMount },
  ] = useForm({
    labelWidth: 120,
    schemas: [
      {
        label: t('预算金额'),
        // field: 'pmZone.projectamount',
        field: 'budgetamount',
        component: 'Input',
        dynamicDisabled: true,
      },
      {
        label: t('发包金额'),
        field: 'lumpamount',
        component: 'Input',
        dynamicDisabled: true,
      },
    ],
    baseColProps: { lg: 8, md: 8 },
  });

  // async function handleSubmit() {
  //   try {
  //     const data = await validate();
  //     setDrawerProps({ confirmLoading: true });
  //     const params: any = {
  //       isNewRecord: record.value.isNewRecord,
  //       id: record.value.id,
  //     };
  //     // console.log('submit', params, data, record);
  //     const res = await pmProjectinformationSave(params, data);
  //     showMessage(res.message);
  //     setTimeout(closeDrawer);
  //     emit('success', data);
  //   } catch (error: any) {
  //     if (error && error.errorFields) {
  //       showMessage(t('您填写的信息有误，请根据提示修正。'));
  //     }
  //     console.log('error', error);
  //   } finally {
  //     setDrawerProps({ confirmLoading: false });
  //   }
  // }

  async function buka() {
    try {
      openFullLoading();
      const params: any = {
        projectno: record.value.projectno,
        ddate: dateValue.value,
        ctype: '1',
      };
      const res = await pmJournalSave(params);
      showMessage(res.message);
      dkjl();
    } catch (error: any) {
      if (error && error.errorFields) {
        showMessage(t('您填写的信息有误，请根据提示修正。'));
      }
      console.log('error', error);
    } finally {
      closeFullLoading();
    }
  }

  function xmwj() {
    openDrawer(true, {});
  }

  function xmzb() {
    openDrawerxmzb(true, {});
  }

  /**
   * 打开报装附件列表
   * @param record
   */
  function handleBzfj() {
    console.log(record);
    // projectno.value = record.value.projectno;
    openAttachmentDrawer();
  }

  /**
   * 打开报装日志列表
   * @param record
   */
  function handleBzLog() {
    // projectno.value = record.value.projectno;
    openBzLogDrawer();
  }

  /**
   * 打开工程日志列表
   * @param record
   */
  function handleGCLog() {
    // projectno.value = record.value.projectno;
    handleSetProject();
    openGcLogDrawer();
  }

  /**
   * 打开工程日志列表
   * @param record
   */
  function handleXmht() {
    // projectno.value = record.value.projectno;
    handleSetProject();
    openXmhtDrawer();
  }

  // 水表清单
  function handleSbqd() {
    openSbqdDrawer();
  }

  // 材料
  function handleClqd() {
    openClqdDrawer();
  }
  function handleClsh() {
    openClshDrawer();
  }
  function handleClcj() {
    openClcjDrawer();
  }
  function handleClqg() {
    openClqgDrawer();
  }
  function handleClkl() {
    openClklDrawer();
  }
  function handleShxq() {
    openShxqDrawer();
  }

  // 过程控制
  function handleXjList() {
    openXjListDrawer();
  }
  function handleSycxList() {
    openSycxListDrawer();
  }
  function handleYqhmList() {
    openYqhmListDrawer();
  }
  function handleJszyList() {
    openJszyListDrawer();
  }
  function handleSzjcList() {
    openSzjcListDrawer();
  }
  function handleTstsbzList() {
    openTstsbzListDrawer();
  }
  function handleCdList() {
    openCdListDrawer();
  }
  function handleFdList() {
    openFdListDrawer();
  }
  function handleGbList() {
    openGbListDrawer();
  }
  function handleCcList() {
    openCcListDrawer();
  }
  function handleGdfcList() {
    openGdfcListDrawer();
  }

  // 打卡记录
  async function dkjl() {
    const res = await pmJournalListCardData({
      projectno: record.value.projectno,
      ddate: dateValue.value,
    });
    date.value = res;
  }

  async function handleSetProject() {
    await switchProject({ id: record.value.id });
    await userStore.setProjecte({
      code: record.value.projectno,
      name: record.value.projectname,
    });
  }

  onMounted(async () => {
    var myDate = new Date();
    let y = myDate.getFullYear();
    let m = myDate.getMonth() + 1 < 10 ? `0${myDate.getMonth() + 1}` : myDate.getMonth() + 1;
    let d = myDate.getDate() < 10 ? `0${myDate.getDate()}` : myDate.getDate();
    dateValue.value = `${y}-${m}-${d}`;

    let viewCode = 'sxyf_proj_info_form_xmxq';
    const res11 = await formSet({ viewCode });
    // formTabs.value = res11.layVoucherView.formTabs;
    // formConfig.value = res11.layVoucherView.formConfig;
    inputFormSchemas = formSchemas(
      res11.layVoucherView.formTabs[0].colList,
      8,
      record.value,
    ) as FormSchema[];
    // await resetFields();
    // const res = await pmProjectinformationForm({ id: router.currentRoute.value.query.id });
    const res = await pmProjectinformationForm({ projectno: router.currentRoute.value.query.code });

    statusMap.value = res.statusMap || {};
    record.value = (res.pmProjectinformation || {}) as PmProjectinformation;
    record.value.__t = new Date().getTime();
    dkjl();

    current.value = record.value.projStatus;
    // setFieldsValue(record.value);
    setProps({
      labelWidth: 120, // 控件前面的标签宽度
      schemas: inputFormSchemas, // 控件定义列表
      // baseColProps: { lg: parseInt(props.formConfig.formColNum), md: 24 },
      baseColProps: { lg: 8, md: 24 },
    });
    await resetFields(); // 重置表单数据
    setFieldsValue(record.value); // 设置字段值

    await resetFieldsMount(); // 重置表单数据
    setFieldsValueMount(record.value); // 设置字段值
  });

  onUnmounted(() => {
    userStore.setProjecte({
      code: '',
      name: '',
    });
  });
</script>
<style scoped>
  /deep/ .ant-form-item-label > label {
    color: #aaa;
  }

  /deep/.ant-steps-item-content {
    width: 100%;
  }

  /deep/.ant-steps-item-description {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* /deep/.ant-steps-item-description{
    max-width: 200px !important;
  } */
  /deep/ .ant-picker-calendar-date-content > div {
    font-size: 15px !important;
    color: red !important;
  }
</style>
